package com.resys.mappers;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface RoomshowMapper {
    @Select("SELECT COUNT(*) FROM roomshow WHERE room_id = #{roomId}")
    Integer getImageCount(Integer roomId);
    @Select("SELECT image_file FROM roomshow WHERE room_id = #{roomId} LIMIT #{index},1")
    String getImgName(Integer roomId, Integer index);
    @Delete("DELETE r FROM roomshow r JOIN (SELECT photo_id FROM roomshow WHERE room_id = #{roomId} LIMIT #{index}, 1) tmp ON r.photo_id = tmp.photo_id;")
    void deleteImg(Integer roomId, Integer index);
    @Insert("insert into roomshow(room_id,image_file) values(#{roomId},#{newFileName})")
    void addImg(Integer roomId, String newFileName);
}
